
import 'package:dali_ng_pera/manager/dnp_cache_manager.dart';
import 'package:dali_ng_pera/page/main/dnp_main_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';

class DnpWelcomeController extends GetxController {

  late BuildContext ctx;

  PageController pageController = PageController();

  int chooseIdx = 0;

  @override
  void onInit() {
    super.onInit();
    pageController.addListener(() {
      chooseIdx = pageController.page!.round();
    });
  }

  void disClick() {
    chooseIdx += 1;
    pageController.animateToPage(
      chooseIdx,
      duration: const Duration(milliseconds: 300),
      curve: Curves.easeInOut,
    );
  }

  void privacyClick() {
    Navigator.of(ctx).push(_createMainWidget());
    DnpCacheManager().saveBool("has_welcome", true);
  }

  Route _createMainWidget() {
    return PageRouteBuilder(
      pageBuilder: (context, animation, secondaryAnimation) => const DnpMainPage(),
      transitionsBuilder: (context, animation, secondaryAnimation, child) {
        return child;
      },
    );
  }
}